import { Component, OnInit } from '@angular/core'
import { Hero } from './models/hero'
import { HeroService } from './services/hero.service'

@Component({
  selector: 'app-hero',
  templateUrl: './hero.component.html',
  styleUrls: [ './hero.component.scss' ],
})
export class HeroComponent implements OnInit {
  title = 'Tour of Heroes'

  heroes = null
  selectedHero: Hero

  constructor(private heroService: HeroService) {
  }

  ngOnInit() {
    this.getHeroes()
  }

  onSelect(hero) {
    this.selectedHero = hero
  }

  getHeroes(): void {
    this.heroes = this.heroService.getHeroes()
  }
}
